package cn.pconline.autoclub.service;

import java.util.Date;

import org.gelivable.dao.GeliDao;
import org.gelivable.dao.GeliOrm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;

import cn.pconline.autoclub.entity.CloudLog;
import cn.pconline.autoclub.util.DateUtils;

/**
 * 融云日志表
 * @author fgs
 *
 */
public class CloudLogService {

    @Autowired
    private GeliOrm geliOrm;
    @Autowired
    private GeliDao geliDao;
	private static final Logger log = LoggerFactory.getLogger(CloudLogService.class);
	
	/**
	 * 创建融云 出错日志表
	 * @param clubId
	 * @param userId
	 * @param type
	 * @return
	 */
	public long create(long clubId,String clubName,long userId,int type){
		Date currentDate=DateUtils.getNow();
		CloudLog cLog = new CloudLog();
		cLog.setClubId(clubId);
		cLog.setClubName(clubName);
		cLog.setUserId(userId);
		cLog.setCreateAt(currentDate);
		cLog.setUpdateAt(currentDate);
		cLog.setStatus(CloudLog.NOT_SEND);
		cLog.setType(type);
		long id = 0;
		try {
			id = geliDao.create(cLog);
		} catch (DataAccessException e) {
			log.error("insert cloud log throws DataAccessException");
		}
		return id;
	}
	
	
}
